#include<iostream>
#include<cstdio>
#define R register
using namespace std; 
int n,m1,m2,now1,now2,cnt,ans,s1[200005],s2[200005],val[3000005],son[3000005][2],a,b;
void putin(int now,int l,int r,int mb,int num)
{
	if (l==r)
	{
		val[now]=num;return;
	}
	R int mid=(l+r)>>1;
	if (mb<=mid)
	{
		if (son[now][0]==0)
			son[now][0]=++cnt,son[cnt][0]=son[cnt][1]=0;
		putin(son[now][0],l,mid,mb,num);
	}
	else
	{
		if (son[now][1]==0)
			son[now][1]=++cnt,son[cnt][0]=son[cnt][1]=0;
		putin(son[now][1],mid+1,r,mb,num);
	}
	val[now]=max(val[son[now][0]],val[son[now][1]]);
}
void find(int now,int l,int r,int mb)
{
	if (val[now]==0||r<mb) return;
	if (l==r)
	{
		now1=l;now2=val[now];return;
	}
	R int mid=(l+r)>>1;
	if (son[now][0]!=0) find(son[now][0],l,mid,mb);
	if (now1==0) find(son[now][1],mid+1,r,mb);
}
void del(int now,int l,int r,int mb)
{
	if (l>mb||r<mb) return;
	if (l==r)
	{
		val[now]=0;return;
	}
	R int mid=(l+r)>>1;
	if (son[now][0]!=0) del(son[now][0],l,mid,mb);
	if (son[now][1]!=0) del(son[now][1],mid+1,r,mb);
	val[now]=max(val[son[now][1]],val[son[now][0]]);
}
int main()
{
	freopen("airport.in","r",stdin);freopen("airport.out","w",stdout);
	scanf("%d%d%d",&n,&m1,&m2);
	cnt=1;son[1][0]=son[1][1]=0;
	for (R int i=1;i<=m1;++i)
		scanf("%d%d",&a,&b),putin(1,1,100000000,a,b);
	for (R int i=1;i<=n;++i)
	{
		s1[i]=s1[i-1];
		now1=0;find(1,1,100000000,0);
		while (now1!=0)
		{
			s1[i]++;
			del(1,1,100000000,now1);
			now1=0;
			find(1,1,100000000,now2);
		}
	}
	cnt=1;son[1][0]=son[1][1]=0;
	for (R int i=1;i<=m2;++i)
		scanf("%d%d",&a,&b),putin(1,1,100000000,a,b);
	for (R int i=1;i<=n;++i)
	{
		s2[i]=s2[i-1];
		now1=0;find(1,1,100000000,0);
		while (now1!=0)
		{
			s2[i]++;
			del(1,1,100000000,now1);
			now1=0;
			find(1,1,100000000,now2);
		}
	}
	ans=0;
	for (R int i=0;i<=n;++i)
		ans=max(ans,s1[i]+s2[n-i]);
	printf("%d",ans);
	return 0;
}
